<template>
	<view class="p-10">
		<view class="card">
			<u-cell-group>
				<u-cell :title="item.title" :value="options[item.prop]" v-for="(item, index) in data"></u-cell>
				<u-cell title="限期日期" :value="options.requireChangeEndDate" v-if="options.changeType == 0"></u-cell>
				<u-cell title="整改人" :value="options.trueChangeUserName" v-if="options.changeType == 1"></u-cell>
				<u-cell title="整改措施" :value="options.changeInfo" v-if="options.changeType == 1"></u-cell>
				<u-cell title="验收人" :value="options.checkUserName" v-if="options.changeType == 1"></u-cell>
				<up-cell title="现场图片" v-if="options.filePaths?.length">
					<template #value>
						<up-image :show-loading="true" :src="url" width="80px" height="80px"></up-image>
					</template>
				</up-cell>
			</u-cell-group>
		</view>

		<view class="card">
			<u-cell-group>
				<u-cell :title="item.title" :value="options1[item.prop]" v-for="(item, index) in data1"></u-cell>
				<up-cell title="整改图片" v-if="options1.filePaths?.length">
					<template #value>
						<up-image :show-loading="true" :src="url1" width="80px" height="80px"></up-image>
					</template>
				</up-cell>
			</u-cell-group>
		</view>

		<view class="card">
			<u-cell-group>
				<u-cell :title="item.title" :value="options2[item.prop]" v-for="(item, index) in data2"></u-cell>
				<up-cell title="签名" v-if="options2.signFilePaths?.length">
					<template #value>
						<up-image :show-loading="true" :src="url3" width="80px" height="80px"></up-image>
					</template>
				</up-cell>
				<up-cell title="验收图片" v-if="options2.filePaths?.length">
					<template #value>
						<up-image :show-loading="true" :src="url2" width="80px" height="80px"></up-image>
					</template>
				</up-cell>
			</u-cell-group>
		</view>

		<view class="card">
			<uni-table ref="table" emptyText="暂无更多数据" stripe>
				<uni-tr>
					<uni-th align="center" width="90">处理时间</uni-th>
					<uni-th align="center" width="70">处理人</uni-th>
					<uni-th align="center" width="80">处理状态</uni-th>
					<uni-th align="center">处理说明</uni-th>
				</uni-tr>
				<uni-tr v-for="(item, index) in tableData" :key="index">
					<uni-td align="center" style="fontsize: 12px !important">
						{{ item.createTime }}
					</uni-td>
					<uni-td align="center" style="fontsize: 12px !important">
						{{ item.createBy }}
					</uni-td>
					<uni-td align="center" style="fontsize: 12px !important">
						{{ item.dealState }}
					</uni-td>
					<uni-td align="center" style="fontsize: 12px !important">
						{{ item.remark }}
					</uni-td>
				</uni-tr>
			</uni-table>
		</view>

		<view class="flex m-t-10" v-if="isIf == 4">
			<u-button style="width: 200rpx" type="primary" shape="circle" text="销号" @click="click"></u-button>
		</view>
	</view>
</template>
<script setup>
import { onLoad } from '@dcloudio/uni-app';
import { ref, unref } from 'vue';
import { infoHiddenDanger } from '@/api/hidden-danger.js';
import { apiBaseURL } from '@/config/index.js';

let options = ref({}),
	data = ref([
		{
			title: '检查类型',
			prop: 'dataTypeName'
		},
		{
			title: '检查人',
			prop: 'inspectUserNames'
		},
		{
			title: '日期',
			prop: 'checkDate'
		},
		{
			title: '隐患内容',
			prop: 'hiddenDangerInfo'
		},
		{
			title: '地点',
			prop: 'riskLocationName'
		},
		{
			title: '隐患成因',
			prop: 'hiddenDangerFactorName'
		},
		{
			title: '隐患等级',
			prop: 'hiddenLevelName'
		},
		{
			title: '整改资金',
			prop: 'changeMoney'
		},
		{
			title: '责任单位',
			prop: 'dutyDeptName'
		},
		{
			title: '责任人',
			prop: 'dutyUserName'
		},
		{
			title: '督办单位',
			prop: 'supervisionDeptName'
		},
		{
			title: '督办人',
			prop: 'supervisionUserName'
		},
		{
			title: '整改方式',
			prop: 'changeTypeName'
		}
	]),
	options1 = ref({}),
	data1 = ref([
		{
			title: '处理类型',
			prop: 'changeTypeName'
		},
		{
			title: '整改单位',
			prop: 'trueChangeDeptName'
		},
		{
			title: '整改人',
			prop: 'trueChangeUserName'
		},
		{
			title: '整改日期',
			prop: 'requireChangeEndDate'
		},
		{
			title: '整改措施',
			prop: 'changeInfo'
		}
	]),
	options2 = ref({}),
	data2 = ref([
		{
			title: '验收日期',
			prop: 'accetpTime'
		},
		{
			title: '验收单位',
			prop: 'accetpDeptName'
		},
		{
			title: '验收人',
			prop: 'accetpUserName'
		},
		{
			title: '验收意见',
			prop: 'accetpMessage'
		}
	]),
	tableData = ref([]);

let url = ref(),
	url1 = ref(),
	url2 = ref(),
	url3 = ref();
let isIf = ref();
onLoad((e) => {
	isIf.value = JSON.parse(e.data)?.stste;
	infoHiddenDanger({
		id: JSON.parse(e.data)?.id
	}).then((res) => {
		tableData.value = res.data?.logs;
		options.value = res.data;
		res.data?.filePaths && res.data.filePaths.length ? (url.value = apiBaseURL + '/rdfile/download/' + res.data.filePaths[0]?.storageUrl) : '';
		options1.value = res.data?.hiddenChangeRequire;
		res.data?.hiddenChangeRequire?.filePaths && res.data?.hiddenChangeRequire.filePaths.length
			? (url1.value = apiBaseURL + '/rdfile/download/' + res.data?.hiddenChangeRequire.filePaths[0]?.storageUrl)
			: '';
		options2.value = res.data?.baseCheckAndAccept;
		res.data?.baseCheckAndAccept?.filePaths && res.data?.baseCheckAndAccept.filePaths.length
			? (url2.value = apiBaseURL + '/rdfile/download/' + res.data?.baseCheckAndAccept.filePaths[0]?.storageUrl)
			: '';
		res.data?.baseCheckAndAccept?.signFilePaths && res.data?.baseCheckAndAccept.signFilePaths.length
			? (url3.value = apiBaseURL + '/rdfile/download/' + res.data?.baseCheckAndAccept.signFilePaths[0]?.storageUrl)
			: '';
	});
});
// 销号
const click = () => {
	uni.navigateTo({
		url: '/pages/professional/hiddenTrouble/end/check?id=' + unref(options).id
	});
};
</script>
<style scoped>
:deep(.u-cell__title) {
	width: 180rpx !important;
}
</style>
